<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <link rel="icon" href="../dist/img/favicon-32x32.png" sizes="32x32" type="image/png">
  <link rel="icon" href="../dist/img/favicon-16x16.png" sizes="16x16" type="image/png">
  <meta name="keywords" content="响应式后台模板,开源免费后台模板,Bootstrap5后台管理系统模板">
  <meta name="description" content="bootstrap-admin基于bootstrap5的免费开源的响应式后台管理模板">
  <meta name="author" content="ajiho">
  <link rel="stylesheet" href="../lib/bootstrap-icons/font/bootstrap-icons.min.css">
  <link rel="stylesheet" href="../lib/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="../dist/css/bootstrap-admin.min.css">
  <title>编辑导师信息</title>
</head>
<body class="bg-body-tertiary py-3">
<div class="container-fluid">
  <div class="card border-0 shadow-sm">
    <div class="card-body">
      <form id="form">
        <div class="row mb-3">
          <label for="instructor_id" class="col-sm-2 col-form-label text-sm-end">导师ID</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="instructor_id" name="instructor_id" value="" required>
          </div>
        </div>
        <div class="row mb-3">
          <label for="instructor_name" class="col-sm-2 col-form-label text-sm-end">导师姓名</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="instructor_name" name="instructor_name" value="" required>
          </div>
        </div>
        <div class="row mb-3">
          <label for="instructor_bio" class="col-sm-2 col-form-label text-sm-end">导师简介</label>
          <div class="col-sm-10">
            <textarea class="form-control" id="instructor_bio" name="instructor_bio" rows="3" required></textarea>
          </div>
        </div>
        <div class="row mb-3">
          <label for="instructor_email" class="col-sm-2 col-form-label text-sm-end">邮箱</label>
          <div class="col-sm-10">
            <input type="email" class="form-control" id="instructor_email" name="instructor_email" value="" required>
          </div>
        </div>
        <div class="row mb-3">
          <label for="instructor_phone" class="col-sm-2 col-form-label text-sm-end">电话</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="instructor_phone" name="instructor_phone" value="" required>
          </div>
        </div>
        <div class="row mb-3">
          <label for="instructor_subject" class="col-sm-2 col-form-label text-sm-end">教授科目</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="instructor_subject" name="instructor_subject" value="" required>
          </div>
        </div>
        <div class="row mb-3">
          <label for="instructor_type" class="col-sm-2 col-form-label text-sm-end">导师类型</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="instructor_type" name="instructor_type" value="" required>
          </div>
        </div>
        <div class="row mb-3">
          <label for="instructor_title" class="col-sm-2 col-form-label text-sm-end">职称</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="instructor_title" name="instructor_title" value="" required>
          </div>
        </div>
        <div class="row mb-3">
          <div class="col-sm-10 offset-sm-2">
            <button type="submit" class="btn btn-primary">保存修改</button>
          </div>
        </div>
      </form>
    </div>
  </div>

  <!--回到顶部开始-->
  <a href="javascript:" class="bsa-back-to-top"><i class='bi bi-arrow-up-short'></i></a>
  <!--回到顶部结束-->

</div>

<script src="../lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="../lib/jquery/dist/jquery.min.js"></script>
<script src="../lib/formvalidation/js/formValidation.js"></script>
<script src="../lib/formvalidation/js/framework/bootstrap.js"></script>
<script src="../lib/formvalidation/js/language/zh_CN.js"></script>
<script src="../dist/js/bootstrap-admin.min.js"></script>
<script src="../dist/js/app.js"></script>
<!--假数据模拟,生产环境中请直接删除该js-->
<script src="../dist/js/bootstrap-admin.mock.js"></script>
<script>

  $(document).ready(function (e) {
    $("#form").formValidation({
      //验证字段
      fields: {
        instructor_id: {
          validators: {
            notEmpty: {
              message: '导师ID为必填项'
            }
          }
        },
        instructor_name: {
          validators: {
            notEmpty: {
              message: '导师姓名为必填项'
            }
          }
        },
        instructor_bio: {
          validators: {
            notEmpty: {
              message: '导师简介为必填项'
            }
          }
        },
        instructor_email: {
          validators: {
            notEmpty: {
              message: '邮箱为必填项'
            },
            emailAddress: {
              message: '邮箱格式不正确'
            }
          }
        },
        instructor_phone: {
          validators: {
            notEmpty: {
              message: '电话为必填项'
            }
          }
        },
        instructor_subject: {
          validators: {
            notEmpty: {
              message: '教授科目为必填项'
            }
          }
        },
        instructor_type: {
          validators: {
            notEmpty: {
              message: '导师类型为必填项'
            }
          }
        },
        instructor_title: {
          validators: {
            notEmpty: {
              message: '职称为必填项'
            }
          }
        }
      }
    }).on('success.form.fv', function (e) {
      //阻止表单提交
      e.preventDefault();
      //得到表单对象
      let $form = $(e.target);
      let data = $form.serialize();

      //发送Ajax请求
      $.ajax({
        url: "/teacher/update", // 这里为更新导师信息的接口
        method: 'post',
        data: data,
        success: function (res) {
          //添加成功
          $.toasts({
            type: 'success',
            content: '修改成功',
            delay: 1000,
            autohide: true,
            onHidden: function () {
              parent.editRoleModal.setData(true); // 刷新父窗口数据
              parent.editRoleModal.close(); // 关闭模态窗口
            }
          });
        }
      });
    });
  });
</script>
</body>
</html>